package com.cy;

import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: Luckyh
 * @date : 2021/4/14 11:01
 */
@SpringBootApplication
//@Slf4j
public class NacosConfigApplication {
    public static void main(String[] args) {
        SpringApplication.run(NacosConfigApplication.class, args);
    }

    private Logger log = LoggerFactory.getLogger(NacosConfigApplication.class);


    @RefreshScope // 支持配置动态刷新
    @RestController
    @RequestMapping("/config/")
    public class NacosConfigController{
        @Value("${logging.level.com.cy:info}")
        private String logLevel;

        @Value("${server.tomcat.threads.max:200}")
        private Integer serverThreads;

        @Value("${page.pageSize:2}")
        private Integer doGetApplication;

        @GetMapping("doGetApplication")
        public Integer doGetApplication(){
            return doGetApplication;
        }

        @GetMapping("doGetThreads")
        public Integer doGetThreads(){
            return serverThreads;
        }

        @GetMapping("doGetLogLevel")
        public String doGetLogLevel(){
            log.debug("debug info");
            log.error("error info");
            return logLevel;
        }
    }



}
